const path = require('path');
const fs = require('fs');
const resolve = dir => path.join(__dirname, dir);

const mockIndexData = require("./data");
let seller = mockIndexData.seller;
let goods = mockIndexData.goods;
let ratings = mockIndexData.ratings;


module.exports = {
  // webpack 配置进行别名的修改
  chainWebpack: (config) => {
    //修改文件引入自定义路径
    config.resolve.alias
    // .set('@', resolve('src'))
    // .set('style', resolve('src/assets/style'))
      .set('components', resolve('src/components'))
      .set('common',resolve('src/common'));
  },
  // 数据mock
  devServer: {
    port: 8080,
    before(apiRoutes) {
      apiRoutes.get("/api/seller", (req, res) => {
        res.json({
          errno: 0,
          data: seller
        });
      });
      apiRoutes.get("/api/goods", (req, res) => {
        res.json({
          errno: 0,
          data: goods
        });
      });
      apiRoutes.get("/api/ratings", (req, res) => {
        res.json({
          errno: 0,
          data: ratings
        });
      });
    }
  }
};

